home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
Libraries
/
Strings
/
PString.h
< prev
next >
Wrap
Text File
|
1997-06-28
|
3KB
|
88 lines
// PString.h
#ifndef PString_h
#define PString_h
#ifndef Assert_h
#include "Assert.h"
#endif
#ifndef Data_h
#include "Data.h"
#endif
#ifndef ConstPString_h
#include "ConstPString.h"
#endif
class PString
{
private:
const Data space;
Data TextSpace() { return space.Tail( 1 ); }
Data SpaceTail( uint32 where ) { return space.Tail( where + 1 ); }
Data UnusedSpace() { return space.Tail( Length() + 1 ); }
public:
PString( Data );
PString( Data, PString );
PString( Data, ConstPString );
PString( Data, ConstStr255Param );
PString( Data, ConstData text );
uint8 Length() const { return space[0]; }
URange32 Range() const { return URange32( 0, Length() ); }
uint32 StorageLength() const { return space.Length(); }
uint32 UnusedLength() const { return space.Length() - space[0] - 1; }
uint8& operator[]( uint32 i ) { Assert( i < Length() ); return space[i+1]; }
const uint8& operator[]( uint32 i ) const { Assert( i < Length() ); return space[i+1]; }
void Clear() { space[0] = 0; }
void Truncate( uint32 end );
void SetLength( uint32 );
Data Text() { return Data( &space[1], Length() ); }
ConstData Text() const { return ConstData( &space[1], Length() ); }
ConstData Head( uint32 size ) const { return Text().Head( size ); }
ConstData Tail( uint32 position ) const { return Text().Tail( position ); }
ConstData Middle( URange32 range ) const { return Text().Middle( range ); }
Data Head( uint32 size ) { return Text().Head( size ); }
Data Tail( uint32 position ) { return Text().Tail( position ); }
Data Middle( URange32 range ) { return Text().Middle( range ); }
void operator=( ConstData );
void operator=( ConstPString string ) { operator=( string.Text() ); }
void operator=( const PString& string ) { operator=( string.Text() ); }
void operator=( ConstStr255Param string ) { operator=( ConstPString( string ) ); }
void operator+=( uint8 c );
void operator+=( ConstData );
void operator+=( ConstPString string ) { operator+=( string.Text() ); }
void operator+=( const PString& string ) { operator+=( string.Text() ); }
void operator+=( ConstStr255Param string ) { operator+=( ConstPString( string ) ); }
operator ConstStr255Param() const { return space.Start(); }
operator ConstPString() const { return ConstPString( space.Start() ); }
operator Data() { return Text(); }
operator ConstData() const { return Text(); }
void Remove( URange32 );
void Insert( uint32 where, uint8 c );
void Insert( uint32 where, ConstData );
void Insert( uint32 where, ConstPString string ) { Insert( where, string.Text() ); }
void Insert( uint32 where, PString string ) { Insert( where, string.Text() ); }
void Insert( uint32 where, ConstStr255Param string ) { Insert( where, ConstPString( string ) ); }
void Replace( URange32 where, uint8 c );
void Replace( URange32 where, ConstData );
void Replace( URange32 where, ConstPString string ) { Replace( where, string.Text() ); }
void Replace( URange32 where, PString string ) { Replace( where, string.Text() ); }
void Replace( URange32 where, ConstStr255Param string ) { Replace( where, ConstPString( string ) ); }
};
#endif